﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
	/// <summary>
	/// MenuItem2.xaml 的交互逻辑
	/// </summary>
	public partial class MenuItem2 : UserControl
	{
		public MenuItem2()
		{
			this.InitializeComponent();
		}

        private bool isSelected = false;

        public bool SARIsSelected
        {
            set
            {
                isSelected = value;
                if (isSelected == true)
                {
                    selectMask.Opacity = 1;
                    Resources["WhiteBrush"] = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
                }
                else
                {
                    selectMask.Opacity = 0;
                    Resources["WhiteBrush"] = new SolidColorBrush(Color.FromArgb(0xff, 0x8D, 0xC1, 0xE8));
                }
            }
            get { return isSelected; }
        }

        private void UserControl_MouseEnter(object sender, MouseEventArgs e)
        {
            if (!isSelected)
            {
                selectMask.Opacity = 1;
                Resources["WhiteBrush"] = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
            }
        }

        private void UserControl_MouseLeave(object sender, MouseEventArgs e)
        {
            if (!isSelected)
            {
                selectMask.Opacity = 0;
                Resources["WhiteBrush"] = new SolidColorBrush(Color.FromArgb(0xff, 0x8D, 0xC1, 0xE8));
            }
        }

        public event MouseButtonEventHandler SARClick;
        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (SARClick != null)
            {
                SARClick.Invoke(this, e);
            }
        }
	}
}